﻿package com.reyco1.jsfl
{
	/*
	imports
	*/
    import flash.display.Sprite
	import adobe.utils.MMExecute
	/*
	class
	*/
	public class JSFLController extends Sprite
	{
		/*
		variables
		*/

		/*
		constructor
		*/
		public function JSFLController():void
		{
		}
		/*
		functions
		*/
		
		/**
		 * Runs a jsfl function within the specified jsfl script
		 * @param objParams: Object with thefollowing mandatory arguments:
		 * 
		 * @param file:String
		 * @param func:String
		 * @param args:Array
		 *
		 * @return String
		 * 
		 */		
		public static function runScript(objParams:Object):String // file, func, args
		{
			var file:String = objParams.file;
			var func:String = objParams.func;
			var result:String;
			
			if( objParams.args.length > 0 ){
				var arg:String = objParams.args.join( "\',\'" );
				result = MMExecute(((((("fl.runScript(fl.configURI+\'WindowSWF/" + file) + "\',\'") + func) + "\',\'") + arg) + "\');");
			}
			else{
				result = MMExecute(((("fl.runScript(fl.configURI+\'WindowSWF/"+ file) + "\',\'") + func) + "\');");
			}			
			
			return( result );
		}
	}	
}
